# -*- encoding=utf8 -*-
__author__ = "yangxianming"

from airtest.core.api import *

auto_setup(__file__)

class EbuyConfig:
    token = "abc"

def openFuYuanWai():
    touch(Template(r"tpl1681354868408.png", target_pos=4, record_pos=(0.23, -0.758), resolution=(1080, 1920)))
    sleep(2.0)
    text("福员外")
    sleep(1.0)
    touch(Template(r"tpl1681354970141.png", record_pos=(0.389, -0.758), resolution=(1080, 1920)))
    sleep(2.0)
    touch(Template(r"tpl1681355016099.png", record_pos=(-0.22, -0.344), resolution=(1080, 1920)))
    sleep(2.0)

def openFYWScene(which_scene=""):
    print(which_scene)
    #外卖
    p1 = Template(r"tpl1681355765860.png", record_pos=(-0.355, 0.125), resolution=(1080, 1920))
    #手机充值
    p2 = Template(r"tpl1681356076004.png", record_pos=(-0.12, 0.13), resolution=(1080, 1920))
    #生活缴费
    p3 = Template(r"tpl1681356086491.png", record_pos=(0.116, 0.125), resolution=(1080, 1920))
    #出行
    p4 = Template(r"tpl1681356098444.png", record_pos=(0.349, 0.128), resolution=(1080, 1920))
    #油卡充值
    p5 = Template(r"tpl1681356107899.png", record_pos=(-0.352, 0.345), resolution=(1080, 1920))
    #停车
    p6 = Template(r"tpl1681356120528.png", record_pos=(-0.119, 0.344), resolution=(1080, 1920))
    #养车
    p7 = Template(r"tpl1681356129645.png", record_pos=(0.115, 0.344), resolution=(1080, 1920))
    #洗车
    p8 = Template(r"tpl1681356141232.png", record_pos=(0.35, 0.336), resolution=(1080, 1920))
    
    #首页搜场景
    pList = [p1, p2, p3, p4, p5, p6, p7, p8]
    pListName = ["waimai","shoujichongzhi","shenghuojiaofei","chuxin","youkachongzhi","tingche","yangche","xiche"] 
    for i in range(len(pList)):
        if pListName[i] == which_scene:
            touch(pList[i])
            break
    
    


def openKoufu():
    #点击工作台
    p1 = Template(r"tpl1679453456429.png", record_pos=(0.0, 0.952), resolution=(1080, 2244))
    p2 = Template(r"tpl1679582467805.png", record_pos=(0.0, 0.952), resolution=(1080, 2244))
    pList = [p1, p2]
    for one in pList:
        if exists(one):
            touch(one)
            break
    sleep(2.0)
    #点击口福生产的图标
    wait(Template(r"tpl1679453507392.png", record_pos=(-0.383, 0.031), resolution=(1080, 2244)), timeout=20, interval=2)
    touch(Template(r"tpl1679453507392.png", record_pos=(-0.383, 0.032), resolution=(1080, 2244)))
    sleep(1.0)
    

def openScene(which_scene=""):
    print(which_scene)
    #首页列出的场景
    #美团外卖
    p1 = Template(r"tpl1679983762364.png", record_pos=(-0.352, -0.452), resolution=(1080, 2244))
    #手机充值
    p2 = Template(r"tpl1679983771286.png", record_pos=(-0.176, -0.456), resolution=(1080, 2244))
    #生活缴费
    p3 = Template(r"tpl1679983781560.png", record_pos=(-0.003, -0.455), resolution=(1080, 2244))
    #领券中心
    p4 = Template(r"tpl1679983841275.png", record_pos=(0.171, -0.447), resolution=(1080, 2244))
    #叮咚买菜
    p5 = Template(r"tpl1679983854182.png", record_pos=(0.346, -0.451), resolution=(1080, 2244))
    #加油
    p6 = Template(r"tpl1679983868295.png", record_pos=(-0.353, -0.294), resolution=(1080, 2244))
    #蛋糕零食
    p7 = Template(r"tpl1679983877541.png", record_pos=(-0.177, -0.294), resolution=(1080, 2244))
    #微医通
    p8 = Template(r"tpl1679983888261.png", record_pos=(0.0, -0.291), resolution=(1080, 2244))
    #特惠电影
    p9 = Template(r"tpl1679983897964.png", record_pos=(0.175, -0.294), resolution=(1080, 2244))
    ##更多#################
    pmore = Template(r"tpl1679983914286.png", resolution=(1080, 2244))
    #更多中搜所将不带坐标
    #美团外卖
    pmore1 = Template(r"tpl1679983762364.png", resolution=(1080, 2244))
    #手机充值
    pmore2 = Template(r"tpl1679983771286.png", resolution=(1080, 2244))
    #生活缴费
    pmore3 = Template(r"tpl1679983781560.png", resolution=(1080, 2244))
    #领券中心
    pmore4 = Template(r"tpl1679983841275.png", resolution=(1080, 2244))
    #叮咚买菜
    pmore5 = Template(r"tpl1679983854182.png", resolution=(1080, 2244))
    #加油
    pmore6 = Template(r"tpl1679983868295.png", resolution=(1080, 2244))
    #蛋糕零食
    pmore7 = Template(r"tpl1679983877541.png", resolution=(1080, 2244))
    #微医通
    pmore8 = Template(r"tpl1679983888261.png", resolution=(1080, 2244))
    #特惠电影
    pmore9 = Template(r"tpl1679983897964.png", resolution=(1080, 2244))
    #体检
    pmore10 = Template(r"tpl1679983947490.png", resolution=(1080, 2244))
    #电影
    pmore11 = Template(r"tpl1679983968451.png", resolution=(1080, 2244))
    #医疗服务
    pmore12 = Template(r"tpl1679983985292.png", resolution=(1080, 2244))
    #大众点评
    pmore13 = Template(r"tpl1679983997497.png", resolution=(1080, 2244))
    
    #首页搜场景
    pList = [p1, p2, p3, p4, p5, p6, p7, p8, p9]
    pListName = ["meituanwaimai","shoujichongzhi","shenghuojiaofei","linquanzhongxin","dingdongmaicai","jiayou","dangaolinshi","weiyitong","tehuidianying"] 
    isFirst = 1
    for i in range(len(pList)):
        if pListName[i] == which_scene:
            touch(pList[i])
            isFirst = 0
            break
    #去更多中搜所
    pmoreList = [pmore1,pmore2,pmore3,pmore4,pmore5,pmore6,pmore7,pmore8,pmore9,pmore10,pmore11,pmore12,pmore13]
    pmoreListName = ["meituanwaimai","shoujichongzhi","shenghuojiaofei","linquanzhongxin","dingdongmaicai","jiayou","dangaolinshi","weiyitong","tehuidianying","tijian","dianyin","yiliaofuwu","dazhongdianpin"] 
    if isFirst:
        touch(pmore)
        sleep(1.0)
        for i in range(len(pmoreList)):
            if pmoreListName[i] == which_scene:
                touch(pmoreList[i])
                break
                
